/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tampilan;

import java.awt.Color;

//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
import java.awt.Font;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//import java.io.BufferedWriter;
//import java.io.FileWriter;


import javax.swing.*;
import javax.swing.JPanel;
import kasus1pendaftaranyudisium.Mahasiswa;
import kasus1pendaftaranyudisium.PengendaliPendaftaranYudisium;

/**
 *
 * @author sony
 */
public class PanelDaftarYudisium extends JPanel {

    private JLabel judul;
    private JLabel labelnim;
    private JTextField textnim;
    private JLabel labelnama;
    private JTextField textnama;
    private JLabel labelprodi;
    private JTextField textprodi;
    private JLabel labelnomorHp;
    private JTextField textnmrHp;
    private JLabel labelperYud;
    private JTextField textperyudtgl;
    private JTextField textperyudbln;
    private JTextField textperyudhari;
    private JLabel labelperYudket;
    private JLabel labellengkap;
    private JCheckBox labelnil;
    private JLabel textnil;
    private JCheckBox labelnaskaTA;
    private JLabel textnaskaTA;
    private JCheckBox labelbebasLab;
    private JLabel textbebasLab;
    private JCheckBox labelbebasDos;
    private JLabel textbebasDos;
    private JCheckBox labelbuktiLapKP;
    private JLabel textbuktiLapKP;
    private JCheckBox labelsrtKKL;
    private JLabel textsrtKKL;
    private JButton tombolbatal;
    private JButton tombolsave;
    private JLabel textfile;
    private JCheckBox labelfile;
    private JLabel textTkbi;
    private JCheckBox labelTkbi;
 private JLabel background;
    public PanelDaftarYudisium() {
        this.setLayout(null);
          background = new JLabel(new ImageIcon("LOGOUSD.jpg"));
        this.add(background);
        background.setBounds(500, 450, 200,100);

        this.setBackground(Color.WHITE);
        judul = new JLabel("**PENDAFTARAN PESERTA YUDISIUM**");
        judul.setBounds(120, 5, 900, 48);
        judul.setFont(new Font("Lucida Handwriting", 3, 20));

        this.add(judul);
        labelnim = new JLabel("Nim");
        labelnim.setBounds(50, 70, 200, 50);
        labelnim.setVisible(true);
        add(labelnim);

        textnim = new JTextField();
        textnim.setBounds(170, 80, 320, 30);
        add(textnim);

        labelnama = new JLabel("Nama");
        labelnama.setBounds(50, 110, 200, 50);
        labelnama.setVisible(true);
        add(labelnama);

        textnama = new JTextField();
        textnama.setBounds(170, 120, 320, 30);
        add(textnama);

        labelnomorHp = new JLabel("No HP");
        labelnomorHp.setBounds(50, 150, 200, 50);
        add(labelnomorHp);
        textnmrHp = new JTextField();
        textnmrHp.setBounds(170, 160, 320, 30);
        add(textnmrHp);
        labelprodi = new JLabel("Prodi");
        labelprodi.setBounds(50, 190, 200, 50);
        add(labelprodi);
        textprodi = new JTextField();
        textprodi.setBounds(170, 200, 320, 30);
        add(textprodi);
        labelperYud = new JLabel("Periode Yudisium");
        labelperYud.setBounds(50, 230, 200, 50);
        add(labelperYud);

        textperyudtgl = new JTextField();
        textperyudtgl.setBounds(170, 250, 60, 30);
        add(textperyudtgl);

        textperyudhari = new JTextField();
        textperyudhari.setBounds(240, 250, 120, 30);
        add(textperyudhari);

        textperyudbln = new JTextField();
        textperyudbln.setBounds(370, 250, 120, 30);
        add(textperyudbln);

        labelperYudket = new JLabel(" *tanggal-hari-bulan");
        labelperYudket.setBounds(500, 240, 200, 50);
        add(labelperYudket);


        labellengkap = new JLabel("Kelengkapan");
        labellengkap.setBounds(50, 270, 200, 50);
        add(labellengkap);

        labelnil = new JCheckBox();
        labelnil.setBounds(170, 295, 20, 20);
        add(labelnil);

        textnil = new JLabel("Daftar Nilai");
        textnil.setBounds(210, 280, 200, 50);
        add(textnil);

        labelnaskaTA = new JCheckBox();
        labelnaskaTA.setBounds(170, 330, 20, 20);
        add(labelnaskaTA);

        textnaskaTA = new JLabel("Naskah TA");
        textnaskaTA.setBounds(210, 315, 200, 50);

        add(textnaskaTA);

        labelbebasLab = new JCheckBox();
        labelbebasLab.setBounds(170, 365, 20, 20);
        add(labelbebasLab);

        textbebasLab = new JLabel("bebas pinjam(lab)");
        textbebasLab.setBounds(210, 350, 200, 50);
        add(textbebasLab);

        labelTkbi = new JCheckBox();
        labelTkbi.setBounds(170, 405, 20, 20);
        add(labelTkbi);
        textTkbi = new JLabel("TKBI/ TOELF");
        textTkbi.setBounds(210, 390, 200, 50);
        add(textTkbi);

        labelbebasDos = new JCheckBox();
        labelbebasDos.setBounds(330, 295, 20, 20);
        add(labelbebasDos);

        textbebasDos = new JLabel("bebas pinjam dari dosen");
        textbebasDos.setBounds(370, 280, 200, 50);
        add(textbebasDos);

        labelbuktiLapKP = new JCheckBox();
        labelbuktiLapKP.setBounds(330, 330, 20, 20);
        add(labelbuktiLapKP);

        textbuktiLapKP = new JLabel("penyerahan laporan KP");
        textbuktiLapKP.setBounds(370, 315, 200, 50);
        add(textbuktiLapKP);

        labelsrtKKL = new JCheckBox();
        labelsrtKKL.setBounds(330, 365, 20, 20);
        add(labelsrtKKL);

        textsrtKKL = new JLabel("surat keterangan KKL/KI");
        textsrtKKL.setBounds(370, 350, 200, 50);
        add(textsrtKKL);

        labelfile = new JCheckBox();
        labelfile.setBounds(330, 405, 20, 20);
        add(labelfile);

        textfile = new JLabel("file keterangan bebas pinjam");
        textfile.setBounds(370, 390, 200, 50);
        add(textfile);


        tombolsave = new JButton("simpan");
        tombolsave.setBounds(150, 500, 120, 30);
        add(tombolsave);
        tombolsave.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                tombolSimpanAction();

            }
        });
        tombolbatal = new JButton("batal");
        add(tombolbatal);
        tombolbatal.setBounds(350, 500, 120, 30);
        tombolbatal.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                tombolBatalAction();
            }
        });
    }

    public void tombolBatalAction() {
        System.exit(0);
    }

    public void tombolSimpanAction() {
        Mahasiswa mhs = new Mahasiswa();
        mhs.setNama(textnama.getText());
        mhs.setNim(textnim.getText());
        mhs.setNoHp(textnmrHp.getText());
        mhs.setTanggal(Integer.parseInt(textperyudtgl.getText()));
        mhs.setHari(textperyudhari.getText());
        mhs.setBulan(textperyudbln.getText());
        mhs.setProdi(textprodi.getText());

        if (labelnil.isSelected() == true) {
            mhs.setDaftar_nilai("Ada");
        } else {
            mhs.setDaftar_nilai("Tidak Ada");
        }

        if (labelnaskaTA.isSelected() == true) {
            mhs.setNaskah_ta("Ada");
        } else {
            mhs.setNaskah_ta("Tidak Ada");
        }

        if (labelbebasLab.isSelected() == true) {
            mhs.setBebaspinjam_lab("Ada");
        } else {
            mhs.setBebaspinjam_lab("Tidak Ada");
        }

        if (labelbebasDos.isSelected() == true) {
            mhs.setBebaspinjam_dosen("Ada");
        } else {
            mhs.setBebaspinjam_dosen("Tidak Ada");
        }

        if (labelbuktiLapKP.isSelected() == true) {
            mhs.setBukti_kp("Ada");
        } else {
            mhs.setBukti_kp("Tidak Ada");
        }

        if (labelbebasLab.isSelected() == true) {
            mhs.setToelf_tkbi("Ada");
        } else {
            mhs.setToelf_tkbi("Tidak Ada");
        }

        if (labelfile.isSelected() == true) {
            mhs.setFile_ket("Ada");
        } else {
            mhs.setFile_ket("Tidak Ada");
        }
        if (labelsrtKKL.isSelected() == true) {
            mhs.setKet_kkl("Ada");
        } else {
            mhs.setKet_kkl("Tidak Ada");
        }
    mhs.setKeterngan("NO Verifikasi");

        JOptionPane.showMessageDialog(this, "Data Mahasiswa" + "\n\nNama: " + mhs.getNama()
                + "\nNim: " + mhs.getNim() + "\nNo Hp: " + mhs.getNoHp()
                + "\nProdi: " + mhs.getProdi() +"\nDATA SUDAH TERDAFTAR"
                );
        PengendaliPendaftaranYudisium.tambahMahasiswa(mhs);
        PengendaliPendaftaranYudisium.tambahTabelMahasiswa(mhs);
        if (labelnil.isSelected() == true && labelnaskaTA.isSelected() == true
                && labelbebasLab.isSelected() == true && labelsrtKKL.isSelected() == true
                && labelbebasDos.isSelected() == true && labelbuktiLapKP.isSelected() == true
                && labelTkbi.isSelected() == true && labelfile.isSelected() == true) {
            JOptionPane.showMessageDialog(null, "Catatan Lampiran lengkap");


        } else {
            JOptionPane.showMessageDialog(null, "Catatan \n Lampiran tidak tidak lengkap ,belum memenuhi syarat ");



        }
    }
}
